<?php
    $is_expired          = osc_item_is_expired () ;
    $is_user             = !( ( osc_logged_user_id() == osc_item_user_id() ) && osc_logged_user_id() != 0 ) ;
    $is_can_contact      = osc_reg_user_can_contact() && osc_is_web_user_logged_in() || !osc_reg_user_can_contact() ;
    
    $is_comments_enabled = osc_comments_enabled() ;
    $is_can_comment      = osc_reg_user_post_comments () && osc_is_web_user_logged_in() || !osc_reg_user_post_comments() ;
?>
<!DOCTYPE html>
<html dir="ltr" lang="<?php echo str_replace('_', '-', osc_current_user_locale()); ?>">
    <head>
        <?php osc_current_web_theme_path('head.php') ; ?>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('fancybox/jquery.fancybox-1.3.4.js') ; ?>"></script>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('bootstrap-modal.js') ; ?>"></script>
        <link href="<?php echo osc_current_web_theme_js_url('fancybox/jquery.fancybox-1.3.4.css') ; ?>" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            $(document).ready(function(){
                $("a[rel=image_group]").fancybox();

                $(".item-contact-button-cancel").bind('click', function(event) {
                    $('#item-contact').modal('hide') ;
                }) ;

                $('#item-contact .close').bind('click', function(event) {
                    $(this).modal('hide') ;
                }) ;
                
                $('#item-sendfriend .close').bind('click', function(event) {
                    $(this).modal('hide') ;
                }) ;

                $(".item-sendfriend-button-cancel").bind('click', function(event) {
                    $('#item-sendfriend').modal('hide') ;
                }) ;
            });
        </script>
        <?php if( osc_item_is_expired () ) { ?>
        <meta name="robots" content="noindex, nofollow" />
        <meta name="googlebot" content="noindex, nofollow" />
        <?php } else { ?>
        <meta name="robots" content="index, follow" />
        <meta name="googlebot" content="index, follow" />
        <?php } ?>
    </head>
    <body>
        <?php osc_current_web_theme_path('header.php') ; ?>
       
         
        <?php while ( osc_has_item_meta() ) { 	
         if(osc_item_meta_name() == "Phone" ) { 
              $m_phone = osc_field(osc_item_meta(), 's_value', '');	             
            } 
         if(osc_item_meta_name() == "VAT" ) { 
              $m_vat = "";
              $m_vat_cod = osc_field(osc_item_meta(), 's_value', '');	
              if($m_vat_cod == 'novatinprice') { $m_vat = 'No VAT in price'; }
              if($m_vat_cod == 'addvattoprice') { $m_vat =  'Add +VAT to price'; }
              if($m_vat_cod == 'partlyvatinprice') { $m_vat = 'Price with partly VAT'; }
              if($m_vat_cod == 'nopayedregistrationtax') { $m_vat = 'No payed registration tax';  }                                                                       
              if($m_vat_cod == 'exportonlyvatisdrawn') { $m_vat = 'Export only VAT is drawn'; }
            } 
         if(osc_item_meta_name() == "B2B" ) { 
             $b2b =  osc_field(osc_item_meta(), 's_value', '');
             if($b2b=="on")
                $m_b2b = 'checked="checked"';	
             else 
                $m_b2b = '';
            } 
          if(osc_item_meta_name() == "GSMPhone" ) { 
              $m_gsmphone = osc_field(osc_item_meta(), 's_value', '');	             
            }
        } ?>
        
        <div class="container item-detail">
            <?php echo twitter_breadcrumb('&raquo;') ; ?>
             <div class="container margin-top-10">
            <?php twitter_show_flash_message() ; ?>
            </div>
            <div class="row">
                <!-- item detail -->
                <div class="content_block">
				
				<div id="item_head">
					
				</div>
				
				<div id="item_main">
                                       
                                     <!-- Dates -->
                                    <div id="dates" style="background:#FFFFFF;color:#28733B;padding:5px;text-align:right;">
                                     <p class="no-margin"><?php printf(__('Published date: <strong>%s</strong>', 'twitter'), osc_format_date( osc_item_pub_date(), "d M Y, H:i" )) ; ?>
                                    <?php if ( osc_item_mod_date() != '' ) { ?>
                                        <span style="margin-left:10px;">
                                    <?php printf(__('Modified date: <strong>%s</strong>', 'twitter'), osc_format_date( osc_item_mod_date(), "d M Y, H:i" )) ; ?>
                                        </span>                                     
                                    <?php } ?>
                                         </p>
                                    </div>
                                    <!-- End dates -->
                                     
                                    <div id="itemHead">                                    
                                     <span class="labelMetro ref">
                                         <?php _e("Ref", 'twitter'); ?> <?php echo osc_item_id(); ?>
                                      </span>
                                      <span class="labelMetro price" style="margin-left:4px;">
                                           <?php if( osc_price_enabled_at_items() ) { ?> 					
					<?php if (price_format(osc_item_formated_price()) != "") { ?>                                           
                                                <?php echo price_format(osc_item_formated_price()) ; ?>
                                         <?php } else { ?>
                                             <?php echo price_format(osc_item_formated_price(),true) ; ?>
                                         <?php } } ?>
                                      </span>
                                      <span style="margin-left:5px;display:inline-block;">
                                          <strong>
                                           <?php if($m_vat!="") printf(__($m_vat, 'twitter')) ; ?> 
                                          </strong>
                                          <?php if($b2b=="on") { ?> <br/> <?php printf(__("b2b", 'twitter')) ; } ?>
                                      </span>                                        
                                      <span class="labelMetro cat" style="float:right;margin-top:5px;">					
                                            <a href="<?php echo osc_item_category_url(osc_item_category_id()) ; ?>"><?php echo osc_item_category(); ?></a>
                                      </span> 
                                    </div>
                                    <h1><?php echo osc_item_title(); ?> </h1> 
					<div style="float:left;">
						<?php //watchlist();?>
					</div>
                   					
					<?php osc_run_hook('item_detail', osc_item() ) ; ?>
					<div class="clear"><br/><br/></div>
					<?php if (osc_item_description() != "" && osc_item_description() != " ") { ?>
					<div class="modal-header-metro metro2"><h5><?php printf(__('additional details', 'twitter')); ?></h5>
                                          <a class="btn item-share-button" style="border-radius: 0px; float: right;height: 15px;margin-right: -6px;margin-top: -22px;" data-controls-modal="item-sendfriend" data-backdrop="true" data-keyboard="true" href="javascript://"><?php _e('Send to a friend', 'twitter') ; ?></a>                                            
                                        </div>
					<div class="alert-normal" style="padding:10px;margin-top:6px;">					
                                            <p><?php echo osc_item_description() ; ?></p>
                                        </div>
					<?php } ?>
                                        <div class="clear"><br/><br/></div>
					<div>		
                                            <?php $item_location = item_detail_location() ; ?>
                                            <?php if( count($item_location) > 0 ) { ?>
                                            <div class="modal-header-metro"><h5><?php printf(__('location', 'twitter')) ; ?> 
                                                    <div style="float:right;"><strong><?php printf(implode(', ', $item_location)); ?></strong></div>
                                                </h5>
                                            </div>       				
                                            <?php osc_run_hook('location') ; }?>
					</div>	
					<br/>
					
					<?php //printf( social_bookmarks("")); ?>
					
		    <div style="float:right;max-width:30%;margin-top:12px;">
                        <?php if ( !$is_expired && $is_user && $is_can_contact ) { ?>
                        <!--<a class="btn primary item-contact-button" data-controls-modal="item-contact" data-backdrop="true" data-keyboard="true" href="javascript://"><?php //_e('Contact seller', 'twitter') ; ?></a>-->
                        <?php } ?>
                        
                    </div>
					
				</div>
				<div id="sidebar" style="float:right;">
                                    <!-- Item User Info -->
					<div id="contact" class="item_contact" style="padding-left:10px;width:306px;">						
						<div class="modal-body" style="padding:0px;">
                                                 <p><strong><center><?php seller_post(); ?></center></strong></p>
                                                 <div style="text-align:center">
                                                <?php if( osc_item_contact_name() != '' ) { ?>
                                                    <p class="name"><?php //_e('Name', 'modern') ?>
                                                        <span style="font-weight:bold;">
                                                                <?php echo osc_item_contact_name()?>
                                                        </span>
                                                        <br/>
                                                        <span><?php echo user_type(); ?></span>
                                                    </p>
                                                <?php } ?>
                                                <?php if( osc_item_show_email() and false) { ?>
                                                    <p class="email">
                                                        <?php //_e('E-mail', 'modern'); ?><span style="font-weight:bold;"><a href="mailto:<?php echo osc_item_contact_email(); ?>"><?php echo osc_item_contact_email(); ?></a></span>
                                                    </p>
                                                 <?php } ?>
                                                
                                                 <div class="custom_fields">
							<?php if( osc_count_item_meta() > 0 ) { ?>
							<div class="meta_list">
								<?php //while ( osc_has_item_meta() ) { ?>
								<?php if( osc_item_show_email()) { ?>
                                                                <?php //if(osc_item_meta_value() != "" && osc_item_meta_name() == "Phone") { ?>
                                                                    <p>
                                                                            <img alt="phone" width="13" src="<?php echo osc_current_web_theme_url('images/phone2.png') ; ?>" />
                                                                            <span style="font-size:22px;font-weight:bold;color:#404040;margin-left:6px;"><?php echo $m_phone;//osc_item_meta_value() ; ?></span>
                                                                    </p>
								<?php //} ?>
                                                                <?php //if(osc_item_meta_value() != "" && osc_item_meta_name() == "GSMPhone") { ?>
                                                                    <p>
                                                                            <img alt="gmsphone" width="16" src="<?php echo osc_current_web_theme_url('images/gmsphone.png') ; ?>" />
                                                                            <span style="font-size:22px;font-weight:bold;color:#404040;margin-left:6px;"><?php echo $m_gsmphone; //osc_item_meta_value() ; ?></span>
                                                                    </p>								
								<?php //} ?>
								<?php } //} ?>
							</div>
							<?php } ?>
						</div>
					        </div>  
                                            
						
						<?php //profile_picture_show(); ?>
						</div>
					</div>
					<!-- End Item User Info -->
                                    
					<!-- Photos -->
					<?php if( osc_images_enabled_at_items() && (osc_count_item_resources() > 0) ) { ?>
                    <!--<div class="photos">
                        <ul class="media-grid">
                        <?php 
						
						//while( osc_has_item_resources() ) { ?>
                            <li>
                                <a rel="image_group" href="<?php //echo osc_resource_url(); ?>"><img src="<?php //echo osc_resource_thumbnail_url(); ?>" width="150" alt="<?php //echo osc_item_title() ; ?>" title="<?php //echo osc_item_title() ; ?>"/></a>
                            </li>
                        <?php ///} ?>
                        </ul>
                    </div>-->
					<div id="photos" class="media-grid">
                        <?php for ( $i = 0; osc_has_item_resources() ; $i++ ) { ?>
                        <a href="<?php echo osc_resource_url(); ?>" rel="image_group" title="<?php _e('Image', 'modern'); ?> <?php echo $i+1;?> / <?php echo osc_count_item_resources();?>">
                            <?php if( $i == 0 ) { ?>
                            <img src="<?php echo osc_resource_url(); ?>" width="307" alt="<?php echo osc_item_title(); ?>" title="<?php echo osc_item_title(); ?>"/>
                            <?php } else { ?>
                                <img src="<?php echo osc_resource_thumbnail_url(); ?>" width="92" alt="<?php echo osc_item_title(); ?>" title="<?php echo osc_item_title(); ?>"/>
                            <?php } ?>
                        </a>
                        <?php } ?>
                    </div>
                    <?php } ?>
					<!-- End Photos -->
									
					
					
				    <?php if ( !$is_expired && $is_user && $is_can_contact ) { ?>
					<!-- item contact -->
					<div id="item-contact" class="item_contact">
						<form class="form-stacked" action="<?php echo osc_base_url(true) ; ?>" method="post" name="contact_form" id="contact_form" onsubmit="return doItemContact() ;" style="background-color:white;padding:0px;border: 1px solid #DDDDDD;margin-bottom:0px;">
							<input type="hidden" name="action" value="contact_post" />
							<input type="hidden" name="page" value="item" />
							<input type="hidden" name="id" value="<?php echo osc_item_id() ; ?>" />
							<div class="modal-header-metro">								
								<h5><?php _e('Contact publisher', 'twitter') ; ?></h5>
							</div>
							<div class="modal-body">
								<?php osc_prepare_user_info() ; ?>   
                                                            
								<div class="clearfix">
									<label for="contact-yourName"><?php _e('Your name', 'twitter') ; ?></label>
									 <div class="input">
                                                                            <input class="xlarge contact-yourName" id="contact-yourName" name="yourName" type="text" value="<?php echo osc_logged_user_name(); ?>">                                                                            
                                                                         </div>
                                                                </div>
								<div class="clearfix">
									<label for="contact-yourEmail"><?php _e('Your e-mail', 'twitter') ; ?></label>
									<div class="input">
                                                                        <input class="xlarge contact-yourEmail" id="contact-yourEmail" name="yourEmail" type="text" value="<?php echo osc_logged_user_email();?>">
                                                                        </div>
								</div>
								<div class="clearfix">
									<label for="contact-phoneNumber"><?php _e('Phone number', 'twitter') ; ?></label>									
									<div class="input">
                                                                        <input class="xlarge contact-phoneNumber" id="contact-phoneNumber" name="phoneNumber" type="text" value="">
                                                                        </div>
								</div>
								<div class="clearfix">
									<label for="contact-message"><?php _e('Message', 'twitter') ; ?></label>									
									<div class="input">
                                                                        <textarea class="xlarge contact-message" id="contact-message" name="message" rows="6"></textarea>									
                                                                        </div>
                                                                </div>
								<?php /*
								<div class="clearfix">
									<?php osc_show_recaptcha(); ?>
								</div>
								*/ ?>
								<div class="clearfix" style="margin-right:2px;margin-bottom:0px;">
								<button class="btngreensimple" type="submit" style="width:100%;"><?php _e('Send', 'twitter') ; ?></button>
								</div>
							</div>
							<!--<div class="modal-footer">								
								<a class="btn item-contact-button-cancel" href="javascript://"><?php //_e('Cancel', 'twitter') ; ?></a>
							</div>-->
						</form>
					</div>
					<!-- item contact end -->
					<?php } ?>					
					
				</div>	
                </div>
                <!-- item detail end -->
                <?php if( $is_comments_enabled ) { ?>
                <!-- comments -->
                <div class="span16 columns comments well">
                    <?php if( $is_can_comment && (osc_item_total_comments() > 0) ) { ?>
                    <h2><?php _e('Comments', 'twitter'); ?></h2>
                    <!-- list comments -->
                    <div class="list-comments">
                        <?php while ( osc_has_item_comments() ) { ?>
                            <div class="comment">
                                <h3><?php echo osc_comment_title() ; ?> <small><em><?php _e("by", 'twitter') ; ?> <?php echo osc_comment_author_name() ; ?></small></em></h3>
                                <p><?php echo osc_comment_body() ; ?> </p>
                                <?php if ( osc_comment_user_id() && (osc_comment_user_id() == osc_logged_user_id()) ) { ?>
                                <p>
                                    <a rel="nofollow" href="<?php echo osc_delete_comment_url() ; ?>" title="<?php _e('Delete your comment', 'twitter') ; ?>"><?php _e('Delete', 'twitter') ; ?></a>
                                </p>
                                <?php } ?>
                            </div>
                        <?php } ?>
                        <?php if( ( !( osc_comments_per_page() == 0 ) || (osc_item_comments_page() === 'all') ) && ( osc_item_total_comments() >= osc_comments_per_page() ) ) { ?>
                        <div class="pagination">
                            <ul>
                                <?php echo twitter_comments_item_pagination() ; ?>
                            </ul>
                        </div>
                        <?php } ?>
                    </div>
                    <!-- list comments end -->
                    <?php } ?>
                    <!-- comment form -->
                    <form action="<?php echo osc_base_url(true); ?>" method="post" name="comment_form" onsubmit="return doComment();" >
                        <input type="hidden" name="action" value="add_comment" />
                        <input type="hidden" name="page" value="item" />
                        <input type="hidden" name="id" value="<?php echo osc_item_id() ; ?>" />
                        <fieldset>
                            <legend><?php _e('Leave your comment', 'twitter') ; ?></legend>
                            <div class="clearfix">
                                <label for="comment-authorName"><?php _e('Your name', 'twitter') ; ?></label>
                                <div class="input">
                                    <input class="xlarge comment-authorName" type="text" value="<?php echo osc_logged_user_name() ; ?>" name="authorName" id="comment-authorName">
                                </div>
                            </div>
                            <div class="clearfix">
                                <label for="comment-authorEmail"><?php _e('Your e-mail', 'twitter') ; ?></label>
                                <div class="input">
                                    <input class="xlarge comment-authorEmail" type="text" value="<?php echo osc_logged_user_email() ; ?>" name="authorEmail" id="comment-authorEmail">
                                </div>
                            </div>
                            <div class="clearfix">
                                <label for="comment-title"><?php _e('Title', 'twitter') ; ?></label>
                                <div class="input">
                                    <input class="xlarge comment-title" type="text" value="" name="title" id="comment-title">
                                </div>
                            </div>
                            <div class="clearfix">
                                <label for="comment-body"><?php _e('Comment', 'twitter') ; ?></label>
                                <div class="input">
                                    <textarea class="xlarge comment-body" id="comment-body" name="body" rows="6"></textarea>
                                </div>
                            </div>
                            <?php /*
                            <div class="clearfix">
                                <?php osc_show_recaptcha(); ?>
                            </div>
                            */ ?>
                            <div class="actions">
                                <button class="btn" type="submit"><?php _e('Post comment', 'twitter') ; ?></button>
                            </div>
                        </fieldset>
                    </form>
                    <!-- comment form end -->
                </div>
                <!-- comments end -->
                <?php } ?>
            </div>
        </div>

        <!-- item send friend -->
        <div id="item-sendfriend" class="modal hide fade item-sendfriend">
            <form class="form-stacked" action="<?php echo osc_base_url(true) ; ?>" method="post" name="sendfriend" onsubmit="return doItemSendFriend() ;">
                <input type="hidden" name="action" value="send_friend_post" />
                <input type="hidden" name="page" value="item" />
                <input type="hidden" name="id" value="<?php echo osc_item_id() ; ?>" />
                <div class="modal-header">
                    <a href="#" class="close">×</a>
                    <h3><?php _e('Send to a friend', 'twitter') ; ?></h3>
                </div>
                <div class="modal-body">
                    <div class="clearfix">
                        <label for="sendfriend-yourName"><?php _e('Your name', 'twitter') ; ?></label>
                        <div class="input">
                            <input class="xlarge sendfriend-yourName" id="sendfriend-yourName" name="yourName" type="text" value="">
                        </div>
                    </div>
                    <div class="clearfix">
                        <label for="sendfriend-friendName"><?php _e('Your e-mail', 'twitter') ; ?></label>
                        <div class="input">
                            <input class="xlarge sendfriend-yourEmail" id="sendfriend-yourEmail" name="yourEmail" type="text" value="">
                        </div>
                    </div>
                    <div class="clearfix">
                        <label for="sendfriend-friendName"><?php _e("Your friend's name", 'twitter') ; ?></label>
                        <div class="input">
                            <input class="xlarge sendfriend-friendName" id="sendfriend-friendName" name="friendName" type="text" value="">
                        </div>
                    </div>
                    <div class="clearfix">
                        <label for="sendfriend-friendEmail"><?php _e("Your friend's e-mail", 'twitter') ; ?></label>
                        <div class="input">
                            <input class="xlarge sendfriend-friendEmail" id="sendfriend-friendEmail" name="friendEmail" type="text" value="">
                        </div>
                    </div>
                    <div class="clearfix">
                        <label for="sendfriend-message"><?php _e('Message', 'twitter') ; ?></label>
                        <div class="input">
                            <textarea class="xlarge sendfriend-message" id="sendfriend-message" name="message" rows="6"></textarea>
                        </div>
                    </div>
                    <?php /*
                    <div class="clearfix">
                        <?php osc_show_recaptcha(); ?>
                    </div>
                    */ ?>
                </div>
                <div class="modal-footer">
                    <button class="btn primary" type="submit"><?php _e('Send', 'twitter') ; ?></button>
                    <a class="btn item-sendfriend-button-cancel" href="javascript://"><?php _e('Cancel', 'twitter') ; ?></a>
				
                </div>	
            </form>
        </div>
        <!-- item send friend end -->
        <script type="text/javascript">
            var text_error_required = '' ;
            var text_valid_email    = '' ;
        </script>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('item_contact.js') ; ?>"></script>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('item_sendfriend.js') ; ?>"></script>
        <script type="text/javascript" src="<?php echo osc_current_web_theme_js_url('item_comment.js') ; ?>"></script>
        <?php osc_current_web_theme_path('footer.php') ; ?>
    </body>
</html>